import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtCharts

Rectangle {
    Layout.fillWidth: true
    Layout.fillHeight: true

    ChartView {
        id: chartView
        title: "主题示例"
        titleFont.bold: true
        titleFont.pointSize: 14

        anchors.fill: parent
        antialiasing: true
        anchors.margins: 25

        theme: ChartView.ChartThemeLight

        ValueAxis {
            id: valueAxisX
            min: 0
            max: 4
            titleText: "X Title"
        }

        ValueAxis {
            id: valueAxisY
            min: 0
            max: 16
            titleText: "Y Title"
        }

        LineSeries {
            name: "line"
            XYPoint { x: 0; y: 0 }
            XYPoint { x: 1; y: 1 }
            XYPoint { x: 2; y: 4 }
            XYPoint { x: 3; y: 9 }
            XYPoint { x: 4; y: 16 }
            axisX: valueAxisX
            axisY: valueAxisY
        }
    }

    Row {
        Text {
            text: "请选择主题："
        }
        ComboBox {
            model: ListModel {
                id: model
                ListElement { text: "ChartThemeLight" }
                ListElement { text: "ChartThemeBlueCerulean" }
                ListElement { text: "ChartThemeDark" }
                ListElement { text: "ChartThemeBrownSand" }
                ListElement { text: "ChartThemeBlueNcs" }
                ListElement { text: "ChartThemeHighContrast" }
                ListElement { text: "ChartThemeBlueIcy" }
                ListElement { text: "ChartThemeQt" }
            }
            onActivated: {
                console.log(currentIndex)
                chartView.theme = currentIndex
            }
        }
    }
}
